package com.heima.common.minio;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(MinIOProperties.class)
public class MinIOConfiguration {

    @Autowired
    private MinIOProperties minIOProperties;

    //创建按Minio连接对象
    @Bean
   public MinioClient getMinioClient(){
        MinioClient minioClient = MinioClient.builder()
                .endpoint(minIOProperties.getEndpoint())   //连接地址
                .credentials(minIOProperties.getAccessKey(), minIOProperties.getSecretKey())   //账号，密码
                .build();
        return minioClient;
    }


}
